package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.pagehelper.PageInfo;
import com.rm.zeyou.entity.Technician;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.TechnicianItemOrderService;
import com.rm.zeyou.util.login.TechnicianLoginUtil;
import com.rm.zeyou.vo.request.*;
import com.rm.zeyou.vo.response.SelectTechnicianOrderDetailsResponseVo;
import com.rm.zeyou.vo.response.SelectTechnicianOrderListResponseVo;
import com.rm.zeyou.vo.response.ServiceEndVo;
import com.rm.zeyou.vo.response.TechnicianCancelOrderDetailResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户订单表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Api(tags = "技师订单相关")
@RestController
@RequestMapping("/api/technicianItemOrder")
public class TechnicianItemOrderController {
    @Resource
    private TechnicianItemOrderService technicianItemOrderService;
    @Resource
    private TechnicianLoginUtil technicianLoginUtil;


    @ApiOperation("技师查看订单列表")
    @PostMapping("selectTechnicianOrderList")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<PageInfo<SelectTechnicianOrderListResponseVo>> selectTechnicianOrderList(@RequestBody SelectTechnicianOrderListVo selectVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.selectTechnicianOrderList(technician, selectVo);
    }


    @ApiOperation("技师查看订单详情")
    @GetMapping("selectTechnicianOrderDetails")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<SelectTechnicianOrderDetailsResponseVo> selectTechnicianOrderDetails(@RequestParam String orderNo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.selectTechnicianOrderDetails(technician, orderNo);
    }

    @ApiOperation("技师接单")
    @PostMapping("takeOrder")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> takeOrder(@RequestBody TakeOrderVo takeOrderVo) throws Exception {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.takeOrder(technician, takeOrderVo);
    }
    @ApiOperation("技师出发")
    @PostMapping("leave")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> leave(@RequestBody LeaveVo leaveVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.leave(technician, leaveVo);
    }

    @ApiOperation("技师到达")
    @PostMapping("arrive")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> arrive(@RequestBody ArriveVo arriveVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.arrive(technician, arriveVo);
    }

    @ApiOperation("技师开始服务")
    @PostMapping("startService")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> startService(@RequestBody StartServiceVo startServiceVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.startService(technician, startServiceVo);
    }

    @ApiOperation("技师结束服务")
    @PostMapping("serviceEnd")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> serviceEnd(@RequestBody ServiceEndVo serviceEndVo) throws Exception {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.serviceEnd(technician, serviceEndVo);
    }

    @ApiOperation("技师评价")
    @PostMapping("technicianAppraise")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> technicianAppraise(@RequestBody TechnicianAppraiseVo technicianAppraiseVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.technicianAppraise(technician, technicianAppraiseVo);
    }

    @ApiOperation("技师取消订单详情")
    @PostMapping("technicianCancelOrderDetail")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<TechnicianCancelOrderDetailResponseVo> technicianCancelOrderDetail(@RequestParam String orderNo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.technicianCancelOrderDetail(technician, orderNo);
    }

    @ApiOperation("技师取消订单")
    @PostMapping("technicianCancelOrder")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> technicianCancelOrder(@RequestBody TechnicianCancelOrderVo technicianCancelOrderVo) throws Exception {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.technicianCancelOrder(technician, technicianCancelOrderVo);
    }


    @ApiOperation("技师打电话")
    @PostMapping("technicianCallTel")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<String> technicianCallTel(@RequestBody TechnicianCallTelVo requestVo) throws Exception {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.technicianCallTel(technician, requestVo);
    }


    @ApiOperation("技师待服务录音")
    @PostMapping("technicianVoice")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> technicianVoice(@RequestBody TechnicianVoiceVo technicianVoiceVo) throws Exception {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianItemOrderService.technicianVoice(technician, technicianVoiceVo);
    }

}
